Fix memory leak of ssl_ext_host_name, losing memory every SSL disconnect#50
Fix memory leak of ssl_ext_host_name, losing memory every SSL disconnect#50igrr merged 1 commit intoigrr:masterfrom earlephilhower:master
Conversation
ssl_ext_set_host_name uses strdup() to set a hostname into the ssl_ext structure, but this memory was not being freed in ssl_ext_free. Add a one-liner to free it during the ssl_ext_free routine, fixing the leak.
|
Thank you for the PR, @earlephilhower! |
Includes two PRs: - igrr/axtls-8266#46 by @earlephilhower: Move debug strings from RAM to Flash - igrr/axtls-8266#50: Fix memory leak in ssl_ext_host_name
|
Until this version 425067a The current fix though relies on the fact that host-name will always be set free(ssl_ext->host_name); |
|
@slaff freeing aan null pointer is perfectly legal in cpp and has no effect |
Yep, that is fine but axTLS can be used in C context. IMHO it would be better if we have code that works well on C and C++. |
|
@slaff same is true for ansi c: if ptr is a null pointer, no action occurs :) |
|
@Jeroen88 is right, passing NULL to |
Includes two PRs: - igrr/axtls-8266#46 by @earlephilhower: Move debug strings from RAM to Flash - igrr/axtls-8266#50: Fix memory leak in ssl_ext_host_name
@Jeroen88 found a memory leak in axtls where the new ext_host_name pointer was leaking on every SSL reconnection, eventually eating up all RAM and crashing the chip (see esp8266/Arduino#3428 ).
This 1-line patch just frees the allocated hostname in during the ssl_ext_free call, eliminating the leakage.